package com.itheima.controller;

import com.itheima.pojo.*;
import com.itheima.service.PetServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/service")
public class PetServiceController {
    @Autowired
    private PetServiceService petServiceService;
    @PostMapping
    public Result add(@RequestBody @Validated PetService petService){
        petServiceService.add(petService);
        return Result.success();
    }
    @GetMapping
    public Result<PageBean<PetService>> list(
            Integer pageNum,
            Integer pageSize,
            @RequestParam(required = false) String username
    ){
        PageBean<PetService> pb = petServiceService.list(pageNum,pageSize,username);
        return Result.success(pb);
    }
    @GetMapping("/detail")
    public Result<List<PetService>> list2(){
        List<PetService> ps = petServiceService.list2();
        return Result.success(ps);
    }
}
